<?php

/**
 * Milestone form.
 *
 * @package    mysmartmanager
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MilestoneForm extends BaseMilestoneForm
{
  public function configure()
  {	
	$this->widgetSchema->setLabels(array(
	  'name'      => 'Milestone Name *',
      'startdate'    => 'Start Date *',
      'enddate'      => 'End Date *',
	  'estimatedcost'      => 'Budget',
	  'createnewplanversion' => 'New Plan Version?',
	));
	

	//$this->project = Doctrine::getTable('Project')->find(array(3));
	//$this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('startdate', '<', 'projectstartdate', array('throw_global_error' => false), array('invalid' => 'The start date must be after the project start date <br />')))));

	$this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('startdate', '<', 'enddate', array('throw_global_error' => false), array('invalid' => 'The start date must be before the end date <br />')))));
    if(sfContext::getInstance()->getUser()->getAttribute('selectedProject') == NULL) {
   		 throw new sfException("Please create some project");
	} else {
		$this->setDefault('projectid', sfContext::getInstance()->getUser()->getAttribute('selectedProject')->getProjectid());
	}
	unset($this['createdate'], $this['createdby'], $this['projectstartdate']);  
  }
}
